import React from 'react';

import { demoUtil } from '../../utils';

import {
  ResourceManager,
  columnFieldsMap,
  ResourceManagerProps,
} from 'easyComponent';

import { commonData } from './commonData';

export default () => {
  const config: ResourceManagerProps = {
    componentsMap: columnFieldsMap,
    rowKey: 'id',
    title: '用户管理',
    fields: [
      {
        label: '姓名',
        name: 'name',
        componentName: 'TextColumnField',
      },
      {
        label: '操作',
        name: 'name',
        componentName: 'OperationColumnField',
        actions: [
          {
            label: '编辑',
            handler: () => {
              demoUtil.toastInfo('你点击了编辑');
            },
          },
        ],
      },
    ],
  };

  return (
    <div>
      <ResourceManager {...config} dataSource={commonData.simpleDataSource} />
    </div>
  );
};
